[HVM] No need to call hvm_do_resume() on every vm entry.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 23 Oct 2006 10:46:41 +0000 (11:46 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 23 Oct 2006 10:46:41 +0000 (11:46 +0100)
Original patch from Xin Li <xin.b.li@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/platform.c
xen/arch/x86/hvm/svm/x86_32/exits.S
xen/arch/x86/hvm/svm/x86_64/exits.S
xen/arch/x86/hvm/vmx/x86_32/exits.S
xen/arch/x86/hvm/vmx/x86_64/exits.S
xen/include/xen/event.h

index 34afeb46e641857d19588f45528b86f202e6f19e..c3b05688030c97bfd722511f1ee881ddad28a6bc 100644 (file)
@@ -237,12 +237,17 @@ void hvm_do_resume(struct vcpu *v)
     }
 
     p = &get_vio(v->domain, v->vcpu_id)->vp_ioreq;
-    wait_on_xen_event_channel(v->arch.hvm.xen_port,
+    wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port,
                               p->state != STATE_IOREQ_READY &&
                               p->state != STATE_IOREQ_INPROCESS);
-    if ( p->state == STATE_IORESP_READY )
+    switch ( p->state )
+    {
+    case STATE_IORESP_READY:
         hvm_io_assist(v);
-    if ( p->state != STATE_INVALID ) {
+        break;
+    case STATE_INVALID:
+        break;
+    default:
         printf("Weird HVM iorequest state %d.\n", p->state);
         domain_crash(v->domain);
     }
index e52464c0dcbcad4c60e48373c4bf7b8be660e3fe..047bb56931fbab8c4164f6f0cdd3b82be7d1f307 100644 (file)
@@ -727,7 +727,8 @@ static void hvm_send_assist_req(struct vcpu *v)
         domain_crash(v->domain);
         return;
     }
-    wmb();
+
+    prepare_wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port);
     p->state = STATE_IOREQ_READY;
     notify_via_xen_event_channel(v->arch.hvm_vcpu.xen_port);
 }
index a2714030fd07bc219072f9df162af3d16e1eb9ce..36fa80b68053fa8e11c1c9095b12dd18f9ebf3ce 100644 (file)
@@ -139,9 +139,6 @@ svm_stgi_label:
 ENTRY(svm_asm_do_resume)
 svm_test_all_events:
         GET_CURRENT(%ebx)
-        pushl %ebx
-        call hvm_do_resume
-        addl $4, %esp
 /*test_all_events:*/
         xorl %ecx,%ecx
         notl %ecx
index 11c62f9d9e2c61d6d3446bafe84ce9d98b2a9edb..823c02378d73d2044450d8630b0637c2369bef3d 100644 (file)
@@ -153,8 +153,6 @@ svm_stgi_label:
 ENTRY(svm_asm_do_resume)
 svm_test_all_events:
         GET_CURRENT(%rbx)
-        movq %rbx, %rdi
-        call hvm_do_resume
 /*test_all_events:*/
         cli                             # tests must not race interrupts
 /*test_softirqs:*/
index 6b6c5536942ccc1367dd09d89d19ab1c42421674..d0ef963b862dcf47615de7791872d581ab979679 100644 (file)
@@ -97,9 +97,6 @@ vmx_process_softirqs:
         ALIGN
 ENTRY(vmx_asm_do_vmentry)
         GET_CURRENT(%ebx)
-        pushl %ebx
-        call hvm_do_resume
-        addl $4, %esp
         cli                             # tests must not race interrupts
 
         movl VCPU_processor(%ebx),%eax
index e7084ebc4c4a373235e5275d83bd7cbdd209d4a3..275e8938b262a426cd01e3872fa32499646138ad 100644 (file)
@@ -106,8 +106,6 @@ vmx_process_softirqs:
         ALIGN
 ENTRY(vmx_asm_do_vmentry)
         GET_CURRENT(%rbx)
-        movq %rbx, %rdi
-        call hvm_do_resume
         cli                             # tests must not race interrupts
 
         movl  VCPU_processor(%rbx),%eax
index 6817681e7dcecb4736e130c133ca8a5fec96c669..39bb8031caef161b9f2bead77fa7cc26c6f764a8 100644 (file)
@@ -70,4 +70,11 @@ void notify_via_xen_event_channel(int lport);
         do_softirq();                                                   \
     } while ( 0 )
 
+#define prepare_wait_on_xen_event_channel(port)                         \
+    do {                                                                \
+        set_bit(_VCPUF_blocked_in_xen, &current->vcpu_flags);           \
+        raise_softirq(SCHEDULE_SOFTIRQ);                                \
+        mb(); /* set blocked status /then/ caller does his work */      \
+    } while ( 0 )
+
 #endif /* __XEN_EVENT_H__ */